<template>
  <div>
    <!-- 头部标签 -->
    <van-nav-bar fixed>
      <template #left>
        <!-- <img class="logo" src="../../assets/toutiao_logo.png" alt="" /> -->
        <img class="logo" :src="imgObj"/>
      </template>
      <template #right>
        <van-icon name="search" size="0.48rem" color="#fff"/>
      </template>

    </van-nav-bar>
    <!-- 频道部分 -->
    <van-tabs v-model="channelId" animated sticky offset-top="1.226667rem">
        <van-tab
        v-for="item in ChannelList"
        :key="item.id"
        :title="item.name"
        :name="item.id">
            <article-list :cid="channelId"></article-list>
        </van-tab>
    </van-tabs>

  </div>
</template>

<script>
import logoPng from '../../assets/toutiao_logo.png'
import { userChannelAPI } from '@/api'
import ArticleList from '@/views/Home/ArticleList'
export default {
  name: 'Home',
  data () {
    return {
      imgObj: logoPng,
      active: 0,
      ChannelList: [],
      channelId: 0
    }
  },
  async created () {
    const res = await userChannelAPI()
    const { channels } = res.data.data
    this.ChannelList = channels
    console.log(this.ChannelList)
  },
  components: {
    ArticleList
  }
}
</script>
<style lang='less' scoped>
.logo {
    width: 100px;
    height: 30px;
}
/* tab内容距离tab导航的距离 */
/deep/ .van-tabs__content{
    padding-top: 44px;
}
</style>
